package reports

import (
	"fmt"
)

//CreateReptFunc 报表创建函数
type CreateReptFunc func(repConf *Config, tName string, paramVals map[string]interface{}) (err error)

var createReptFuncPool map[string]CreateReptFunc

//SetCreateReptFunc 获取报表创建函数
func SetCreateReptFunc(name string, crf CreateReptFunc) {
	createReptFuncPool[name] = crf
}

//GetOneValueFunc 获取报表创建函数
func GetOneValueFunc(name string) (crf CreateReptFunc, err error) {
	crf, ok := createReptFuncPool[name]
	if !ok {
		err = fmt.Errorf("指定的函数名称%s不存在", name)
	}
	return
}

func init() {
	createReptFuncPool = make(map[string]CreateReptFunc)
	createReptFuncPool["createLineColumnData"] = createLineColumnData
	createReptFuncPool["createPieData"] = createPieData
	createReptFuncPool["createDateRangeData"] = createDateRangeData
	createReptFuncPool["createDataChangeAnalysis"] = createDataChangeAnalysis
	createReptFuncPool["createDataRangeAnalysis"] = createDataRangeAnalysis
	createReptFuncPool["createDataRangeKhs"] = createDataRangeKhs
}
